#ifndef LEXER_HPP
#define LEXER_HPP

#include "tokens.hpp"

#include <cstdio>
#include <iostream>

class TokenBase;

class Lexer
{
	public:
	
	Lexer( std::istream& );
	~Lexer();
	
	Tkn::Token peek() const;
	Lexer& consume();
	
	size_t getLineNumber() const;
	const std::string& getTokenContent() const;
	
	private:
	
	typedef char char_t; // The character type
	
	char_t* fill( size_t n, char_t* cursor ); // Buffer fill function used by RE2C
	
	size_t lineNumber; // Current line number
	Tkn::Token currentToken; // Current recognized token
	std::string tokenContent;
	
	std::istream* input; // Input stream that fills the buffer
	char_t* buffer; // The buffer
	size_t bufferSize; // Current size of the buffer
	char_t* bottom; // Pointer to the bottom of the buffer queue
	char_t* top; // Pointer to the top of the buffer queue
	char_t* marker; // Needed by RE2C

};

#endif // LEXER_HPP
